/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package bullets;

import java.util.LinkedList;
import java.util.List;

/**
 *
 * @author ajt019
 */
public class Bullets {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        
        
        IBoard mainBoard = new Board(10, 10);
        
        // setup example game
          
        mainBoard.markField(0, 0, FieldType.TYPE_1);
        mainBoard.markField(0, 1, FieldType.TYPE_1);
        mainBoard.markField(0, 2, FieldType.TYPE_1);
        mainBoard.markField(0, 3, FieldType.TYPE_1);
        mainBoard.markField(0, 4, FieldType.TYPE_1);
      
        mainBoard.markField(0, 0, FieldType.TYPE_1);
        mainBoard.markField(1, 0, FieldType.TYPE_1);
        mainBoard.markField(2, 0, FieldType.TYPE_1);
        mainBoard.markField(3, 0, FieldType.TYPE_1);
        mainBoard.markField(4, 0, FieldType.TYPE_1);
        mainBoard.markField(5, 0, FieldType.TYPE_1);
        mainBoard.markField(10, 0, FieldType.TYPE_1); // rem
        
        mainBoard.markField(1, 1, FieldType.TYPE_2);
        mainBoard.markField(2, 2, FieldType.TYPE_2);
        mainBoard.markField(3, 3, FieldType.TYPE_2);
        mainBoard.markField(4, 4, FieldType.TYPE_2);
        mainBoard.markField(5, 5, FieldType.TYPE_2);
        
        mainBoard.markField(0, 9, FieldType.TYPE_2);
        mainBoard.markField(1, 8, FieldType.TYPE_2);
        mainBoard.markField(2, 7, FieldType.TYPE_2);
        mainBoard.markField(3, 6, FieldType.TYPE_2);
        mainBoard.markField(4, 5, FieldType.TYPE_2);
        mainBoard.markField(5, 4, FieldType.TYPE_2);
        mainBoard.markField(6, 3, FieldType.TYPE_2);
        mainBoard.markField(7, 2, FieldType.TYPE_2);
        mainBoard.markField(8, 1, FieldType.TYPE_2);
        mainBoard.markField(9, 0, FieldType.TYPE_2);
        
        mainBoard.markField(1, 0, FieldType.TYPE_3);
        mainBoard.markField(2, 1, FieldType.TYPE_3);
        mainBoard.markField(3, 2, FieldType.TYPE_3);
        mainBoard.markField(4, 3, FieldType.TYPE_3);
        
        LinkedList< LinkedList<Field> > linie = mainBoard.checkLines();
        if (linie.isEmpty())
        {
            System.out.println("No bingos found");
            System.exit(0);
        }
        
        System.out.println("linie size:" + linie.size() ); 
        for(List<Field> linia : linie)
        {
           if (linia.isEmpty())
           {
              System.out.println("Discrepancy found(1)! " 
                      + Thread.currentThread().getStackTrace()[1].getMethodName()
                      + ": " + Thread.currentThread().getStackTrace()[1].getLineNumber()); 
           }
           else
           {
               System.out.print("Found " + linia.size() + " elements line long: ");
               for(Field field : linia)
               {
                   if (field == null)               
                       System.out.println("Discrepancy found(2)! " + Thread.currentThread().getStackTrace()[1].getMethodName()                    + ": " + Thread.currentThread().getStackTrace()[1].getLineNumber());
                   else
                       System.out.print("("+field.m_x +"," + field.m_y + ") " );
               }
               System.out.println();
           }                       
        }
    }
}
